﻿<Window 
    xmlns:entities="clr-namespace:Acme.Entities;assembly=Acme.Entities"
    xmlns:local="clr-namespace:Acme.Basic"
    x:Class="Acme.Basic.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Family Event Manager" Icon="/Acme.Basic;component/EventManager.ico" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="500" Width="800" Loaded="Window_Loaded">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="225" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <Image Height="36" HorizontalAlignment="Left" Stretch="Uniform" VerticalAlignment="Top" Width="36" Source="/Acme.Basic;component/Images/EventManager.png" Margin="6" />
        <TextBlock HorizontalAlignment="Left" Margin="60,0,0,0" Text="Family Event Manager - Basic" VerticalAlignment="Center" Grid.ColumnSpan="2" FontSize="24" />

        <Border Grid.Row="1" Margin="6,6,3,6" BorderBrush="LightGray" BorderThickness="1" CornerRadius="10">
            <Grid d:DataContext="{d:DesignInstance entities:Event, CreateList=True}">
                <ListBox Name="lbEvents" Margin="6" SelectionChanged="lbEvents_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Width="190">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="70" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="{Binding Path=EventDate, StringFormat=\{0:MM/dd/yyyy\}}"  />
                                <TextBlock Text="{Binding Path=Title}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Grid.Column="1" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </Border>

        <Border Margin="3,6,6,6" Grid.Column="1" Grid.Row="1" BorderBrush="LightGray" BorderThickness="1" CornerRadius="10">
            <Grid Name="DetailsForm" Margin="6" d:DataContext="{d:DesignInstance entities:Event}" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label Content="Title" Margin="6" />
                <Label Content="Location" Grid.Row="1" Margin="6" />
                <Label Content="Date" Grid.Row="2" Margin="6" />
                <Label Content="Notes" Grid.Row="3" Margin="6" />
                
                <TextBox Name="txtTitle" Grid.Column="1" Margin="6" Text="{Binding Path=Title, Mode=TwoWay}" />
                <TextBox Name="txtLocation" Grid.Column="1" Grid.Row="1" Margin="6"  Text="{Binding Path=Location, Mode=TwoWay}"/>
                <DatePicker Name="dpEventDate" Grid.Column="1" Grid.Row="2" Margin="6"  Text="{Binding Path=EventDate, Mode=TwoWay}"/>
                <TextBox Name="txtNotes" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" Grid.Column="1" Grid.Row="3" Margin="6" Height="50" Text="{Binding Path=Notes, Mode=TwoWay}"/>

                <DataGrid AutoGenerateColumns="False" AlternationCount="2"  Grid.Column="1" Grid.Row="4" Name="dgExpenses" Margin="6" ItemsSource="{Binding Path=Expenses}">
                    <DataGrid.Columns>
                        <DataGridTextColumn Binding="{Binding Recipient}" Header="Recipient" Width="100" />
                        <DataGridTextColumn Binding="{Binding Cost, StringFormat=\{0:c\}}" Width="75" Header="Cost" />
                        <DataGridTextColumn Binding="{Binding Description}" Header="Description" />
                    </DataGrid.Columns>
                </DataGrid>
                
                <StackPanel Orientation="Horizontal" Grid.Row="5" Grid.ColumnSpan="2" >
                    <Button Content="New" Height="23" HorizontalAlignment="Left" Margin="6" Name="btnNew" VerticalAlignment="Top" Width="75" Click="btnNew_Click" />
                    <Button Content="Save" Height="23" HorizontalAlignment="Left" Margin="6" Name="btnSave" VerticalAlignment="Top" Width="75" Click="btnSave_Click" />
                    <Button Content="Cancel" Height="23" HorizontalAlignment="Left" Margin="6" Name="btnCancel" VerticalAlignment="Top" Width="75" Click="btnCancel_Click" />
                    <Button Content="Delete" Height="23" HorizontalAlignment="Left" Margin="6" Name="btnDelete" VerticalAlignment="Top" Width="75" Click="btnDelete_Click" />
                    <Button Content="Throw" Height="23" HorizontalAlignment="Left" Margin="6" Name="btnThrow" VerticalAlignment="Top" Width="75" Click="btnThrow_Click" />
                </StackPanel>
            </Grid>
        </Border>

    </Grid>
</Window>
